package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysProductApply;
import com.ruoyi.system.domain.dto.apply.ProductApplyDto;
import com.ruoyi.system.service.ISysProductApplyService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 审核申请Controller
 */
@Api(tags = "审核申请")
@RestController
@RequestMapping("/system/apply")
public class SysExamineApplyController extends BaseController
{
    @Autowired
    private ISysProductApplyService sysProductApplyService;

    /**
     * 查询产品申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysProductApply sysProductApply)
    {
        startPage();
        List<SysProductApply> list = sysProductApplyService.selectSysProductApplyList(sysProductApply);
        return getDataTable(list);
    }


    /**
     * 获取产品申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysProductApplyService.selectSysProductApplyById(id));
    }

    /**
     * 修改产品申请
     */
    @Log(title = "产品申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysProductApply sysProductApply)
    {
        return toAjax(sysProductApplyService.updateSysProductApply(sysProductApply));
    }


    /**
     * 审核
     */
    @PostMapping("/examineApply")
    public AjaxResult examineApply(ProductApplyDto productApplyDto)
    {
        return toAjax(sysProductApplyService.examineApply(productApplyDto));
    }



}
